home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 27
/
Commodore_Free_Issue_27_2009_Commodore_Computer_Club.d64
/
vic ram
< prev
next >
Wrap
Text File
|
2023-02-26
|
7KB
|
272 lines
..
Understanding VIC-20 Ram Expansion
One of the most confusing things about
the VIC-20 is the screwy way that
memory locations shift around when you
add RAM expansion. Add 8K of RAM or
more & everything changes: suddenly
Screen & Colour Memory move to
different locations. Old programs for
the unexpanded VIC that POKE to the
screen or use redefined character
graphics no longer work. Depending on
the amount of RAM expansion you have,
BASIC even begins in different
locations. Aargh!
The diagrams on this page all come
from Leif Bloomquist's C= VIC-20
Memory Blocks Illustrated. (See VIC20
MEMORY article on this disk)
http://8bitcentral.com/files/
vicmemory.pdf
This PDF helped me a lot in my quest
to figure all this out. Click HERE
http://home.ica.net/{$de}leifb/
commodore/index.htm
to visit Leif's site.
Also, Anders Persson has written a
great tutorial:
http://user.tninet.se/{$de}pug510w/
datormuseum/expandedvic20.html
(ED Reproduced in this issue of
C= FREE) Graphics & Bigger Screen in
BASIC on the Expanded VIC-20. Anders'
website is HERE.
Another good resource is the book VIC
Revealed, by Nick Hampshire. If you
want to really understand how the VIC
works, you owe it to yourself to get
this book. It's fairly common, you can
often find it on eBay.
http://www.ebay.com/
Like most things, it doesn't seem that
hard once you figure it all out ...
FIGURING IT ALL OUT
DEC HEX BLOCK
-------------------
57344 E000 Block7
49152 C000 Block6
40960 A000 Block5
32768 8000 Block4
24576 6000 Block3
16384 4000 Block2
8192 2000 Block1
0 0000 Block0
-------------------
Let's imagine the VIC's memory as a
series of 8K "blocks," starting at
0000 (block 0) & ending with block 7
(E000). Expansion RAM can be placed in
blocks: 1,2,3 & 5. There's also a
little 3K slice available in block 0
that we'll talk about later.
If you put 8K in blocks 1,2,& 3 your
VIC will have 29K total RAM available
to BASIC. That's the 5K the VIC came
with plus 8K in blocks 1,2 & 3. RAM
has to be contiguous to be seen by
BASIC. That is, BASIC only sees RAM
as a single big chunk of memory. Since
blocks 1 - 3 are right next to each
other, the VIC can see all of it as
one big 24K hunk of RAM. So, looking
at the diagram, you can understand why
24K is the maximum amount of RAM
expansion available to BASIC.
BLOCK 5
You've no doubt observed that block 5
is not contiguous with blocks 1,2,& 3.
Block 4 is in the way. So BASIC can't
see RAM in block 5. You might be
asking yourself: If RAM in block 5 is
invisible to BASIC, what good is it?
You can place machine language
programs in block 5, or use the RAM to
store data that can be read with
BASIC's PEEK statement. So, RAM in
block 5 can still be quite useful. The
only thing you can't use it for is to
add to the RAM available for BASIC
programs.
Another feature of block 5 is that
programs stored in this area can be
"auto-started" when the VIC is reset.
Most cartridge games are located in
block 5. You can tell because these
games start automatically when you
turn the VIC on. To further illustrate
the Programmers' Aid Cartridge puts
its program in block 3. That explains
why you have to enter SYS 28681 to
launch the Programmers' Aid. Only
programs located in block 5 will start
automatically when you reset the VIC.
It sounds pretty straight forward,
doesn't it? Can it really be this
simple? Unfortunately, the answer is
No. We're going to have to take a
look at what's in block 0 & block 4 to
see where things get a little tricky.
BLOCK 0
DEC HEX BLOCK
-----------------
57344 E000 BLOCK7
49152 C000 BLOCK6 38912 9800 I/O
40960 A000 BLOCK5 38400 9600 Scn
Color mem
32768 8000 BLOCK4 ---> 37800 9400 ---
24576 6000 BLOCK3 36864 9000
VIC/VIA
16384 4000 BLOCK2 32968 8000 Char
ROM
8192 2000 BLOCK1
0000 0000 BLOCK0 ---> 7680 1E00 Scn
memory
4608 1200 User BASIC
4696 1000 " "
1024 0400 3k Available
0000 0000 Basic working
Memory
The diagram above blows up blocks 0 &
4 so we can see their contents. Take a
close look at block 0 on the unex-
panded VIC. The area, from 1000 to
1DFF, is User BASIC Area. This is RAM
that's available for BASIC programs.
This one tiny little slice of block 0
is all the RAM we have to work with.
Not much, is it? Let's start adding
some RAM & see what happens.
ADDING 3K
The section from 0400 to 0FFF in our
block 0 diagram is a 3K area set aside
for RAM expansion. This is where the
RAM in Commodore's 3K RAM Expansion
cartridge or 3K Super Expander goes.
After adding one of these cartridges
our block 0 diagram looks like this:
------------------------------
7680 1E00 Screen mem
------------------------------
4608 1200 User BASIC area
---------
4696 1000 " " "
---------
1024 0400 " " "
------------------------------
0 0000 BASIC working Memory
------------------------------
And there we have it-- The beginning
of BASIC moves down to 0400 & we now
have an extra 3K of RAM to work with.
Now let's add an 8K RAM cartridge to
block 1.
BLOCK 1
8k RAM CARTRIDGE INSTALLED
8192 2000
------------------------------
7680 1E00 Screen memory
------------------------------
4608 1200 User BAsic area
---------
1024 0400 " " "
------------------------------
0000 0000 BASIC working memory
------------------------------
The diagram above represents our VIC
with 3K expansion, plus 8K in block 1.
Uh oh, there's a problem. Do you see
it? Remember, all RAM available to
BASIC must be in a single continuous
chunk. Screen Memory (1E00 - 1FFF) is
separating the User BASIC Area from
the 8K expansion we want to put in
block 1. What do we do? There's only
one thing we can do: we have to move
Screen Memory somewhere else. The VIC
does this automatically when you add
expansion RAM to block 1. Here's what
block 0 & 1 look like after adding 8K
to block 1.
BLOCK 1
8k RAM CARTRIDGE INSTALLED
8192 2000
------------------------------
7680 1E00 User BASIC Area
4608 1200 " " "
------------------------------
4096 1000 Screen Memory
------------------------------
1024 0400 3K Available
------------------------------
0 0000 BASIC Working Memory
------------------------------
Screen Memory moves from 1E00 to 1000.
Now we can add 8K to blocks 1,2,& 3 &
all the BASIC RAM will be in one
continuous chunk. BASIC now begins at
1200 & runs until the end of expansion
RAM. One more detail: Colour Memory
in block 4 has to be a precise
distance from Screen Memory. Since we
moved Screen Memory, Colour Memory
will have to move too-- from 9600 down
to 9400.
Hey, what about my 3K RAM at 0400?
Since Screen Memory is now separating
our 3K area from the User Basic Area,
RAM in the 3K area becomes invisible
to BASIC just like RAM in block 5.
It's a trade-off, but it allows us to
fill blocks 1 - 3 with RAM that can be
used by BASIC.
The next article on this disk "VIC20
MEMORY" ties it all together with a
diagram showing all the possible
memory configurations. Note how Screen
Memory (block 0) & Colour Memory
(block 4) move to different locations
when adding 8K+ of RAM expansion.
..end..